package com.zhike.common.component;

import org.springframework.stereotype.Component;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class SnowflakeID {

    private Snowflake snowflake;

    public SnowflakeID() {
        //参数1为终端ID
        //参数2为数据中心ID
        snowflake = IdUtil.getSnowflake(1, 1);
    }

    public long nextId() {
        return snowflake.nextId();
    }

    public String nextIdStr() {
        return snowflake.nextIdStr();
    }
}